#ifndef BUFFER_H
#define BUFFER_H

#include <string>
using namespace std;
class Buffer
{
public:
    Buffer(int size);
    ~Buffer();

    void extendRoom(int size);

    inline int writeableSize() {
        return m_capacity - m_writePos;
    }

    inline int readablesize() {
        return m_writePos - m_readPos;
    }

    int appendString(const char* data, int size);

    int appendString(const char* data);

    int appendString(const string data);

    int socketRead(int fd);

    char* findCRLF();

    int sendData(int socket);

    inline char* data() {
        return m_data + m_readPos;
    }

    inline int readPosIncrease(int count) {
        m_readPos += count;
        return m_readPos;
    }



private:
    char* m_data = nullptr;
    int m_capacity = 0;
    int m_readPos = 0;
    int m_writePos = 0;
};

#endif // BUFFER_H
